package org.todd.healthreport.tasks;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.todd.healthreport.service.IDongDaHealthReportService;
import org.todd.healthreport.service.Impl.HealthReportServiceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Configurable
@EnableScheduling
public class myTask {

    @Autowired
    private HealthReportServiceImpl healthReportService;

    @Autowired
    private IDongDaHealthReportService dongDaHealthReportService;


    @Scheduled(cron = "0 3 8 1/1 * ?")
    public void scheduledTasksExecute(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(new Date())+"开始报备数据");
        healthReportService.healthReport();
        System.out.println(sdf.format(new Date())+"报备完成");
    }

    @Scheduled(cron = "0 30 7 1/1 * ?")
    public void scheduledTasksExecuteDongDa(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(new Date())+"开始报备数据");
        dongDaHealthReportService.doHealthReport();
        System.out.println(sdf.format(new Date())+"报备完成");
    }

}
